﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Share_WebTimer : System.Web.UI.UserControl
{
    protected string second = "";
    /// <summary>
    /// 0 代表尚未开始
    /// 1 已开始未结束
    /// 2 已结束
    /// </summary>
    protected string status = "";
    protected void Page_Load(object sender, EventArgs e)
    {

        //尚未开始
        if (DateTime.Now < BeginTime)
        {
            status = "0";
            //距离开始时间
            second = ((BeginTime.Ticks - DateTime.Now.Ticks) / TimeSpan.TicksPerSecond).ToString();
            toEndTime.Visible = false;
        }
        //开始了，尚未结束
        if (DateTime.Now > BeginTime && DateTime.Now < EndTime)
        {
            status = "1";
            second = ((EndTime.Ticks - DateTime.Now.Ticks) / TimeSpan.TicksPerSecond).ToString();
            toBeginTime.Visible = false;
        }
        //已经结束了
        if (DateTime.Now > EndTime)
        {
            status = "2";
            toEndTime.Visible = false;
            toBeginTime.Visible = false;
        }
    }

    public DateTime EndTime { get; set; }

    public DateTime BeginTime { get; set; }
}
